package com.origin.onlinesys.web.controllers.modules.interviewsys;

import com.alibaba.fastjson.JSON;
import com.origin.onlinesys.common.controllers.BaseController;
import com.origin.onlinesys.domain.modules.interviewsys.Zone;
import com.origin.onlinesys.service.modules.interviewsys.impl.ZoneServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Created by Administrator on 2015/1/23 0023.
 * 校区
 */

@RequestMapping(value = "/management/zone/")
@Controller
public class ZoneController  extends BaseController {
    @Autowired
    private ZoneServiceImpl service;

    @RequestMapping(value = "/findAll")
    @ResponseBody
    public List<Zone>  findAll(){
        return service.selectAllZone();
    }

    @RequestMapping(value = "/findByStateY")
    public @ResponseBody
    List<Zone> findByStateY(){
        return service.selectByState("1");
    }

    @RequestMapping(value = "/findByStateN")
    public @ResponseBody
    List<Zone> findByStateN(){
        return service.selectByState("2");
    }

    @RequestMapping(value = "/add")
    public @ResponseBody
    Zone addZone(@ModelAttribute Zone zone){
        System.out.println(JSON.toJSONString(service.insertZone(zone)));
        return zone;
    }

    @RequestMapping(value = "/update")
    public void updateZone(@ModelAttribute Zone zone){
        service.updateZone(zone);
    }

    @RequestMapping(value = "/del")
    public @ResponseBody
    String deleteZone(String id){
        service.deleteZone(id);
        return "1";
    }
}
